package middleware

import (
	"admin/tools"
	"github.com/gin-gonic/gin"
)

// 认证用户
func AuthJwt() gin.HandlerFunc {
	return func(c *gin.Context) {
		// 获取用户 token
		token := c.GetHeader("token")
		user, err := tools.ValidateJWT(token)
		if err == nil {
			c.Set("user", user)
		}
		c.Next() // 调用该行代码以继续执行后续处理程序
	}

}
